<!-- 时钟校准 -->
<div class="card">
    <h2><span class="menu__icon">🕒</span> 时钟校准</h2>
    <div class="control-item">
        <p>从NTP服务器同步设备时间。当前设备时间: <strong id="maintenance-device-time">正在获取...</strong></p>
        <button id="sync-time-btn" class="btn">立即校准</button>
    </div>
</div>

<!-- 设备重启 -->
<div class="card">
    <h2><span class="menu__icon">🔄</span> 设备重启</h2>
    <p>点击下方按钮将立即重启设备。所有未保存的配置将会丢失。</p>
    <button id="reboot-device-btn" class="btn btn-warning">立即重启</button>
</div>

<!-- 管理员账户修改 -->
<div class="card">
    <h2><span class="menu__icon">🔑</span> 修改管理员密码</h2>
    <form id="change-password-form">
        <div class="form-group">
            <label for="current-password">当前密码</label>
            <input type="password" id="current-password" name="current_password" required>
        </div>
        <div class="form-group">
            <label for="new-password">新密码</label>
            <input type="password" id="new-password" name="new_password" required>
        </div>
        <div class="form-group">
            <label for="confirm-password">确认新密码</label>
            <input type="password" id="confirm-password" name="confirm_password" required>
        </div>
        <button type="submit" class="btn">更新密码</button>
    </form>
</div>

<!-- 恢复出厂设置 -->
<div class="card">
    <h2><span class="menu__icon">🗑️</span> 恢复出厂设置</h2>
    <p class="warning-text"><strong>警告：</strong>此操作不可逆！所有网络、服务和账户配置都将被清除，设备将恢复到初始状态。</p>
    <button id="factory-reset-btn" class="btn btn-danger">执行恢复出厂设置</button>
</div>

<!-- 固件升级 (OTA) -->
<div class="card">
    <h2><span class="menu__icon">🚀</span> 固件升级 (OTA)</h2>
    <div class="form-group">
        <label>当前固件版本</label>
        <p id="current-firmware-version" class="info-text">v1.0.0 (正在获取...)</p>
    </div>

    <!-- Tab 切换按钮 -->
    <div class="ota-tabs">
        <button id="tab-btn-upload" class="ota-tab-btn active" data-tab="upload">文件上传</button>
        <button id="tab-btn-url" class="ota-tab-btn" data-tab="url">从 URL 升级</button>
    </div>

    <!-- Tab 内容 -->
    <div class="ota-tab-content-wrapper">
        <!-- 文件上传内容 -->
        <div id="ota-tab-upload" class="ota-tab-content active">
            <div class="form-group">
                <label for="firmware-file">选择固件文件 (.bin)</label>
                <input type="file" id="firmware-file" name="firmware" accept=".bin">
            </div>
            <button id="upload-firmware-btn" class="btn">上传并升级</button>
        </div>

        <!-- URL 升级内容 -->
        <div id="ota-tab-url" class="ota-tab-content">
            <div class="form-group">
                <label for="firmware-url">固件 URL 地址</label>
                <input type="url" id="firmware-url" name="firmware_url" placeholder="http://example.com/firmware.bin" required>
            </div>
            <button id="url-upgrade-btn" class="btn">开始升级</button>
        </div>
    </div>
    
    <!-- 统一的升级进度显示区域 -->
    <div id="ota-progress-container" class="progress-container">
        <label id="ota-progress-label">升级进度</label>
        <div class="progress-bar">
            <div id="ota-progress-bar" class="progress-bar-inner"></div>
        </div>
        <span id="ota-progress-text">0%</span>
    </div>
    <p id="ota-status-message" class="info-text"></p>
</div>